package net.neocat.tcx.file;

import com.google.common.collect.ImmutableList;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jschek
 * Date: 4/24/13
 * Time: 11:38 PM
 * To change this template use File | Settings | File Templates.
 */
public class TcxCourse {
    private final String courseName;
    private final double totalDistanceMeters;
    private final int totalTimeSeconds;
    private final GeoPosition beginPosition;
    private final GeoPosition endPosition;
    private final List<TrackPoint> trackPoints;
    private final List<CoursePoint> coursePoints;

    public TcxCourse(String courseName, double totalDistanceMeters, int totalTimeSeconds, GeoPosition beginPosition, GeoPosition endPosition, List<TrackPoint> trackPoints, List<CoursePoint> coursePoints) {

        this.courseName = courseName;
        this.totalDistanceMeters = totalDistanceMeters;
        this.totalTimeSeconds = totalTimeSeconds;
        this.beginPosition = beginPosition;
        this.endPosition = endPosition;
        this.trackPoints = ImmutableList.copyOf(trackPoints);
        this.coursePoints = ImmutableList.copyOf(coursePoints);
    }

    @Override
    public String toString() {
        return "TcxCourse{" +
                "courseName='" + courseName + '\'' +
                ", totalDistanceMeters=" + totalDistanceMeters +
                ", totalTimeSeconds=" + totalTimeSeconds +
                ", beginPosition=" + beginPosition +
                ", endPosition=" + endPosition +
                ", trackPoints=" + trackPoints +
                ", coursePoints=" + coursePoints +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TcxCourse tcxCourse = (TcxCourse) o;

        if (Double.compare(tcxCourse.totalDistanceMeters, totalDistanceMeters) != 0) return false;
        if (totalTimeSeconds != tcxCourse.totalTimeSeconds) return false;
        if (beginPosition != null ? !beginPosition.equals(tcxCourse.beginPosition) : tcxCourse.beginPosition != null)
            return false;
        if (courseName != null ? !courseName.equals(tcxCourse.courseName) : tcxCourse.courseName != null) return false;
        if (coursePoints != null ? !coursePoints.equals(tcxCourse.coursePoints) : tcxCourse.coursePoints != null)
            return false;
        if (endPosition != null ? !endPosition.equals(tcxCourse.endPosition) : tcxCourse.endPosition != null)
            return false;
        if (trackPoints != null ? !trackPoints.equals(tcxCourse.trackPoints) : tcxCourse.trackPoints != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        result = courseName != null ? courseName.hashCode() : 0;
        temp = Double.doubleToLongBits(totalDistanceMeters);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        result = 31 * result + totalTimeSeconds;
        result = 31 * result + (beginPosition != null ? beginPosition.hashCode() : 0);
        result = 31 * result + (endPosition != null ? endPosition.hashCode() : 0);
        result = 31 * result + (trackPoints != null ? trackPoints.hashCode() : 0);
        result = 31 * result + (coursePoints != null ? coursePoints.hashCode() : 0);
        return result;
    }

    public String getCourseName() {

        return courseName;
    }

    public double getTotalDistanceMeters() {
        return totalDistanceMeters;
    }

    public int getTotalTimeSeconds() {
        return totalTimeSeconds;
    }

    public GeoPosition getBeginPosition() {
        return beginPosition;
    }

    public GeoPosition getEndPosition() {
        return endPosition;
    }

    public List<TrackPoint> getTrackPoints() {
        return trackPoints;
    }

    public List<CoursePoint> getCoursePoints() {
        return coursePoints;
    }
}
